<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Class CreateMedicalPresentillnessSubTable
 * 现病史字表  用来做现病史分组
 */
class CreateMedicalPresentillnessSubTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('st_medical_presentillness_sub', function (Blueprint $table) {
            $table->increments('id')->comment('现病史字表,用来做现病史分组');
            $table->unsignedInteger('record_id')->index()->comment("关联medical_records_id");
            $table->date('started_at')->comment('起病日期');
            $table->unsignedTinyInteger('inducement')->comment('诱因：1无明显诱因，2情绪波动 3压力大 4劳累 5产后 6 其他');
            $table->unsignedInteger('clinic_site', 32)->comment('就诊地点');
            $table->string('symptoms')->comment('起病症状,多个起病症状以逗号隔开');
            $table->text('before_treatment')->nullable()->comment('用药前化验');
            $table->text('after_treatment')->nullable()->comment('治疗后血糖值');
            $table->text('diagnose')->nullable()->comment('诊断');
            $table->text('medication')->nullable()->comment("用药情况");
            $table->text('cn_medication')->nullable()->comment("用药情况");
            $table->unsignedTinyInteger('type')->comment('1.现病史中添加的，2.随诊中添加的');
            $table->softDeletes();
            $table->timestamps();

            //  索引
            $table->index(['record_id', 'type']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('st_medical_presentillness_sub');
    }
}
